import os
import sqlite3
from app import create_app

def check_teams():
    """检查数据库中的战队信息"""
    app = create_app()
    
    with app.app_context():
        db_path = os.path.join(app.instance_path, 'esports.db')
        if not os.path.exists(db_path):
            print("数据库文件不存在")
            return
        
        # 使用SQLite直接连接
        conn = sqlite3.connect(db_path)
        cursor = conn.cursor()
        
        try:
            # 检查teams表的结构
            cursor.execute("PRAGMA table_info(teams)")
            columns = cursor.fetchall()
            
            print("Teams表结构:")
            for col in columns:
                print(f"{col[1]} - {col[2]} - {col[3]}")
            
            # 获取所有战队信息
            cursor.execute("SELECT * FROM teams")
            teams = cursor.fetchall()
            
            if teams:
                print(f"\n共有 {len(teams)} 个战队:")
                for team in teams:
                    print(f"ID: {team[0]}, 名称: {team[1]}, 联赛: {team[5]}, 游戏: {team[6]}, 图标: {team[7]}")
            else:
                print("\n没有战队记录")
            
        except Exception as e:
            print(f"检查失败: {str(e)}")
        finally:
            conn.close()

if __name__ == "__main__":
    check_teams() 